Xbasic

INDEX.RECORDS_GET Function

Syntax

Number_of_Records as N = Records_Get()

Description

Gets the number of records in an index.

Discussion

The .RECORDS_GET() method retrieves the Number_of_Records selected by the specified index tag.

Example

For example, to return the number of records in the primary index for the current table, you might use:

dim tbl as P
dim indx as P
tbl = table.current()
indx = tbl.index_primary_get()
records = indx.records_get()

If you have a script that prints a report, you might want to execute the report query first to be sure that some records are selected. If no records are selected, you do not want to print the report. The following script fragment tests the number of records found by a query:

tbl = table.current()
query.description = "test query"
'order by the Priority field
query.order = "priority"
'select only records for UPS Red
query.filter = "ship_via = 'UPS Red'"
'do not use any query options
query.options = "I"
'run query
i = tbl.query_create()
'get number of records selected
recs_found = i.records_get()
'test recs_found
if (recs_found = 0) then
    ui_msg_box("Sorry!", "No matches were found.")
else
    'Print the report
    :report.print("custmer_report")
end if

If you use the .RECORDS_GET() method with an unfiltered index, it will return the total number of records in the table. If used with filtered indexes and query lists, the method will return the number of records that satisfied the filter criteria.

See Also